Fix VBD recovery logic on SMP guests (+ a minor error reporting fix for save)
authorsmh22@firebug.cl.cam.ac.uk <smh22@firebug.cl.cam.ac.uk>
Thu, 1 Dec 2005 19:43:04 +0000 (20:43 +0100)
committersmh22@firebug.cl.cam.ac.uk <smh22@firebug.cl.cam.ac.uk>
Thu, 1 Dec 2005 19:43:04 +0000 (20:43 +0100)
Signed-off-by: Steven Hand <steven@xensource.com>
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
tools/libxc/xc_linux_save.c

index 7357d14b60f8bd8aca8b6da1630c996f65c98688..0200c779fb8ad2bf8fe05a01083ca828c981dbdc 100644 (file)
@@ -300,6 +300,10 @@ static void backend_changed(struct xenbus_device *dev,
 /* ** Connection ** */
 
 
+/* 
+** Invoked when the backend is finally 'ready' (and has told produced 
+** the details about the physical device - #sectors, size, etc). 
+*/
 static void connect(struct blkfront_info *info)
 {
        unsigned long sectors, sector_size;
@@ -324,20 +328,17 @@ static void connect(struct blkfront_info *info)
                return;
        }
        
-        info->connected = BLKIF_STATE_CONNECTED;
         xlvbd_add(sectors, info->vdevice, binfo, sector_size, info);
-       
-       err = xenbus_switch_state(info->xbdev, NULL, XenbusStateConnected);
-       if (err)
-               return;
+
+       (void)xenbus_switch_state(info->xbdev, NULL, XenbusStateConnected); 
        
        /* Kick pending requests. */
        spin_lock_irq(&blkif_io_lock);
+       info->connected = BLKIF_STATE_CONNECTED;
        kick_pending_request_queues(info);
        spin_unlock_irq(&blkif_io_lock);
 }
 
-
 /**
  * Handle the change of state of the backend to Closing.  We must delete our
  * device-layer structures now, to ensure that writes are flushed through to
@@ -770,11 +771,20 @@ static void blkif_recover(struct blkfront_info *info)
 
        kfree(copy);
 
-       /* Kicks things back into life. */
+       (void)xenbus_switch_state(info->xbdev, NULL, XenbusStateConnected); 
+       
+       /* Now safe for us to use the shared ring */
+       spin_lock_irq(&blkif_io_lock);
+        info->connected = BLKIF_STATE_CONNECTED;
+       spin_unlock_irq(&blkif_io_lock);
+
+       /* Send off requeued requests */
        flush_requests(info);
 
-       /* Now safe to let other people use the interface. */
-       info->connected = BLKIF_STATE_CONNECTED;
+       /* Kick any other new requests queued since we resumed */
+       spin_lock_irq(&blkif_io_lock);
+       kick_pending_request_queues(info);
+       spin_unlock_irq(&blkif_io_lock);
 }
 
 
index 2d15ee587dee0eb9f1d98d0a1cd22c0018d655c2..1c32ed8a803311e46988e7ed8d8ab560af109254 100644 (file)
@@ -677,7 +677,7 @@ int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
                              live_shinfo->arch.pfn_to_mfn_frame_list_list);
 
     if (!live_p2m_frame_list_list) {
-        ERR("Couldn't map p2m_frame_list_list");
+        ERR("Couldn't map p2m_frame_list_list (errno %d)", errno);
         goto out;
     }